<template>
  <el-container style="width: 100%; padding: 10px">
    <el-aside>
      <profile-info :userinfo="userinfo_"></profile-info>
    </el-aside>
    <el-main style="padding-top: 0px;">
      <profile-form :userinfo="userinfo" @update="getUserInfo"></profile-form>
    </el-main>
  </el-container>
</template>

<script>
  import ProfileForm from './components/ProfileForm'
  import ProfileInfo from './components/ProfileInfo'
  export default {
    components: {
      ProfileInfo,
      ProfileForm
    },
    name: 'Profile',

    data: function() {
      return {
        userinfo: {
          ssn: null,
          username: null,
          phoneNum: null,
          orgName: null,
          roleName: null,
        },
        userinfo_: {
          ssn: null,
          username: null,
          phoneNum: null,
          orgName: null,
          roleName: null,
        }
      }
    },
    created() {
      this.getUserInfo()
    },
    methods: {
      getUserInfo() {
        this.$api.getCurrentUserInfo().then(res => {
          this.userinfo = res;
          this.userinfo_ = {...res};
        })
      },
    }
  }
</script>

<style scoped>

</style>
